﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IPC.Communication.Core.IMessage
{
    public class OpenProtocolMessage : INetMessage
    {
        public int ProtocolHeadBytesLength
        {
            get
            {
                return 4;
            }
        }

        public byte[] SendBytes
        {
            get;
            set;
        }

        public byte[] HeadBytes
        {
            get;
            set;
        }

        public byte[] ContentBytes
        {
            get;
            set;
        }

        public bool CheckHeadBytesLegal(byte[] token)
        {
            bool flag = this.HeadBytes == null;
            return !flag;
        }

        public int GetContentLengthByHeadBytes()
        {
            byte[] expr_07 = this.HeadBytes;
            bool flag = expr_07 != null && expr_07.Length >= 4;
            int result;
            if (flag)
            {
                result = Convert.ToInt32(Encoding.ASCII.GetString(this.HeadBytes, 0, 4)) - 4;
            }
            else
            {
                result = 0;
            }
            return result;
        }

        public int GetHeadBytesIdentity()
        {
            return 0;
        }
    }
}
